using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
	/// <summary> 
	///Author: daiduong19051986@gmail.com 
	/// <summary>
    public class IcunitConversionsControl
    {
		#region Local Variable
        private IcunitConversionsDataAccess _objDAO;
		#endregion Local Variable
		
		#region Method
        public IcunitConversionsControl()
        {
            _objDAO = new IcunitConversionsDataAccess();
        }
		
        public IcunitConversionsInfo Get(
        String Monedb,
        String Unitfrom,
        String Unitto,
		ref string sErr)
        {
            return _objDAO.Get(
            Monedb,
            Unitfrom,
            Unitto,
			ref sErr);
        }
		
        public DataTable GetAll(
        ref string sErr)
        {
            return _objDAO.GetAll(
            ref sErr);
        }
		
        public Int32 Add(IcunitConversionsInfo obj, ref string sErr)
        {
            return _objDAO.Add(obj, ref sErr);
        }
		
        public string Update(IcunitConversionsInfo obj)
        {
            return _objDAO.Update(obj);
        }
		
        public string Delete(
        String Monedb,
        String Unitfrom,
        String Unitto
		)
        {
            return _objDAO.Delete(
            Monedb,
            Unitfrom,
            Unitto
			);
        }  
        public Boolean IsExist(
        String Monedb,
        String Unitfrom,
        String Unitto
		)
        {
            return _objDAO.IsExist(
            Monedb,
            Unitfrom,
            Unitto
			);
        } 
		
        public DataTable Search(String columnName, String columnValue, String condition, String tableName, ref String sErr)
        {           
            return _objDAO.Search(columnName, columnValue, condition, tableName, ref  sErr);
        }
        public string InsertUpdate(IcunitConversionsInfo obj)
        {
            string sErr = "";
            if (IsExist(
            obj.Monedb,
            obj.Unitfrom,
            obj.Unitto
			))
            {
                sErr = Update(obj);
            }
            else
                Add(obj, ref sErr);
            return sErr;
        }
		
        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
			IcunitConversionsInfo inf = new IcunitConversionsInfo();
            return inf.ToDataTable();
        }
		
		public string TransferIn(DataRow row)
        {
            IcunitConversionsInfo inf = new IcunitConversionsInfo(row);
            return InsertUpdate(inf);
        }
		#endregion Method


        public DataTable GetSearch(string strFilter, string Monedb, ref string sErr)
        {
            return _objDAO.GetFilter(strFilter, Monedb, ref sErr);
        }
    }
}
